import dayjs from 'dayjs'

export default class Article {
    static insertObj ({name = null, content = null, category_id = null, user_id = null, cover_imgs = null, article_imgs = null, article_videos = null }) {
        if(name !== null && content !== null && category_id !== null && user_id !== null){
            return {
                name,
                content,
                update_time: dayjs().format('YYYY-MM-DD HH:MM:ss'),
                cover_imgs: JSON.stringify(cover_imgs),
                article_imgs: JSON.stringify(article_imgs),
                article_videos: JSON.stringify(article_videos),
                category_id,
                user_id
            }
        }else {
            return false
        }
    }

    static deleteObj ({id = null}) {
        if(id !== null){
            return {
                id
            }
        }else {
            return false
        }
    }

    static updateObj ({id = null, name = null, content = null, category_id = null, user_id = null, cover_imgs = null, article_imgs = null, article_videos = null}) {
        if(id !== null){
            return {
                id,
                name,
                content,
                update_time: dayjs().format('YYYY-MM-DD HH:MM:ss'),
                cover_imgs: JSON.stringify(cover_imgs),
                article_imgs: JSON.stringify(article_imgs),
                article_videos: JSON.stringify(article_videos),
                category_id,
                user_id
            }
        }else {
            return false
        }
    }
}